demo.js ➔ ... ➔ ???
last analyzed

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
nc 1
dl 0
loc 3
nop 1
1
import {
2
	DeviceVisibility
3
} from '../../controls';
4
5
export class Demo {
6
7
	constructor( saveUI, preview ) {
8
		this.saveUI = saveUI;
9
		this.preview = preview;
10
	}
11
12
	render() {
13
		let $tab = $( '.device-visibility' ),
14
			$demoElement = $tab.find( '.demo-element' ),
0 ignored issues
show
Unused Code introduced by
The variable $demoElement seems to be never used. Consider removing it.
Loading history...
15
			name = 'deviceVisibility',
16
			control = new DeviceVisibility( {
17
				defaults: this.saveUI.getItem( 'deviceVisibility' ),
18
				control: {
19
					selectors: [ '.demo-element' ]
20
				}
21
			} );
22
23
		// Render the control.
24
		$tab.find( '.control' ).html( control.render() );
25
26
		// On change of the control, update the styles.
27
		control.events.on( 'change', ( settings ) => {
28
			this.preview.appendStyles( name, settings.css );
29
		} );
30
31
		// When the user clicks on save, save the settings.
32
		this.saveUI.setup( name, () => control.getSettings() );
33
34
		// On Load, append the current setting styles to the head.
35
		this.preview.appendStyles( name, control.getSettings().css );
36
	}
37
}
38